package com.wangsb;

/**
 * @Description: TODO
 * @author: shenbing.wang@hand-china
 * @date: 2021年06月20日 12:55
 */
public class Code0301 {

    public static void main(String[] args) {
        String str = "ABCD123!@#$%ab";
        char[] chars = str.toCharArray();
        //统计大写字母
        int capitalLetterSum = 0;
        //统计大写字母统计小写字母
        int minusculesSum = 0;
        //統計數字
        int numSum = 0;
        //統計其他字符
        int otherCharSum = 0;
        for (char aChar : chars) {
            String s = String.valueOf(aChar);
            if (s.matches("[A-Z]")) {
                capitalLetterSum++;
            }
            if (s.matches("[a-z]")) {
                minusculesSum++;
            }
            if (s.matches("[0-9]")) {
                numSum++;
            }
            otherCharSum = str.length() - capitalLetterSum - minusculesSum - numSum;
        }

        System.out.println("capitalLetterSum = " + capitalLetterSum);
        System.out.println("otherCharSum = " + otherCharSum);
        System.out.println("numSum = " + numSum);
        System.out.println("minusculesSum = " + minusculesSum);
    }
}
